package com.itheima.day15.TCP.test9;

import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ConnectException;
import java.net.Socket;
import java.net.SocketException;

public class ChatInput implements Runnable {
    private Socket accept;

    public ChatInput(Socket accept) {
        this.accept = accept;
    }

    @Override
    public void run() {

        while (true) {
            try {
                //网络中的流
                InputStreamReader isr = null;
                isr = new InputStreamReader(accept.getInputStream());
                int b;
                while ((b = isr.read()) != -1) {
                    System.out.print((char) b);
                }
                //System.out.println("接受成功");
            } catch (SocketException e) {
                e.printStackTrace();
            } finally {
                break;
            }
        }

    }
}
